package net.dodoman;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

class PanelDemo extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6707899689363055251L;
	JPanel panlMain;

	public PanelDemo() {
		panlMain = new JPanel(new GridLayout(2, 1));
		TopPanel tPanel = new TopPanel();
		BottomPanel bPanel = new BottomPanel();
		this.setContentPane(panlMain);
		// this.getContentPane().add(pnlMain);
		panlMain.add(tPanel);
		panlMain.add(bPanel);
		setTitle("Panel演示程序");
		setSize(400, 350);
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);

	}

	public static void main(String args[]) {
		new PanelDemo();

	}
}

// 上部面板
class TopPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8999561629434590868L;
	JLabel lblWelcome;
	JLabel lblTop;

	public TopPanel() {
		lblWelcome = new JLabel("欢迎进入JAVA世界！");
		lblTop = new JLabel("上部面板");
		setLayout(new GridLayout(2, 1));
		add(lblWelcome);
		add(lblTop);

	}
}

// 下部面板
class BottomPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7732839631515848319L;
	JLabel lblBottom;
	JButton btnExit;

	public BottomPanel() {

		lblBottom = new JLabel("下部面板");
		btnExit = new JButton("点击退出");
		add(lblBottom);
		add(btnExit);
	}
}
